import wrftools
import sys



config = wrftools.read_namelist(sys.argv[1]).settings

#
# Set up the logger. This must be done immediately
# after the config is read.
#
logger      = wrftools.create_logger(config)
init_times   = wrftools.get_init_times(config)



wrftools.clear_tmp_dir(config)

for init_time in init_times:
     
    #
    # Update the configuration state
    #
    config['init_time'] = init_time.strftime('%Y-%m-%d %H:%M:%S') # update the inital time
    logger.info('*** WORKING ON INITIAL TIME %s ***' %init_time) 
    
    wrftools.point_stat_gfs(config)
    #wrftools.extract_gfs_fields(config)